package com.crrc.dataparse.monitor.rsp.service.parse.treat.templatepara.datatrans;

import com.crrc.dataparse.templatepara.IDataTrans;

/*
    2进制转ASCII码字符串
 */
public class TransAsciiAg1 extends IDataTrans {
    public TransAsciiAg1() {
    }
    @Override
    public String trans(String value, double resolusion, double offset) {
        char[] bytes = new char[value.length() / 8];

        for(int i = 0; 8 * i < value.length(); ++i) {
            bytes[i] = (char)Integer.parseInt(value.substring(i * 8, i * 8 + 8), 2);
        }

        return new String(bytes);
    }
}
